﻿using System;
using System.Drawing;

namespace ClickToCall.CustomControls
{
    static class Common
    {
        public static PointF GetTextPosition(ContentAlignment alignment, Size clientSize, SizeF textSize)
        {
            PointF p = new PointF();
            p.X = (clientSize.Width - textSize.Width) / 2;
            p.Y = (clientSize.Height - (textSize.Height + 4)) / 2;
            switch (alignment)
            {
                case ContentAlignment.TopCenter:
                    p.Y = 2;
                    break;
                case ContentAlignment.TopLeft:
                    p.Y = 2;
                    p.X = 8;
                    break;
                case ContentAlignment.TopRight:
                    p.Y = 2;
                    p.X = clientSize.Width - (textSize.Width + 4);
                    break;
                case ContentAlignment.MiddleCenter:
                    break;
                case ContentAlignment.MiddleLeft:
                    p.X = 8;
                    break;
                case ContentAlignment.MiddleRight:
                    p.X = clientSize.Width - (textSize.Width + 4);
                    break;
                case ContentAlignment.BottomCenter:
                    p.Y = clientSize.Height - (textSize.Height + 4);
                    break;
                case ContentAlignment.BottomLeft:
                    p.Y = clientSize.Height - (textSize.Height + 4);
                    p.X = 8;
                    break;
                case ContentAlignment.BottomRight:
                    p.Y = clientSize.Height - (textSize.Height + 4);
                    p.X = clientSize.Width - (textSize.Width + 4);
                    break;
                default:
                    break;
            }
            return p;
        }

    }
}
